<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>添加</title>
    <link href="${request.contextPath}/static/ihomeStatic/css/bootstrap.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/css/font-awesome.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/css/animate.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/css/style.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/js/layer/mobile/need/layer.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/js/treeTable/css/treeTable.min.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ihomeStatic/js/icheck/css/custom.css" rel="stylesheet">
</head>
<body class="fixed-sidebar full-height-layout">
<input type="hidden" id="h1">
<body class="gray-bg">
<div class="wrapper">
    <div class="row">
        <div class="ibox">
            <div class="ibox-content">
                <form  class="form-horizontal" id="defaultForm"   action=""  method="post" onsubmit="return false;">

                    <input id="parentId" name="parentId" class="form-control" value="${menu.menuId}" type="hidden"/>
                    <input name="id" class="form-control" type="hidden" value=""/>

                    <div class="form-group"><label class="col-sm-2 control-label">上级菜单</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <#if menu??>
                                    <input id="menuName" name="parent.name" readonly="readonly" type="text" value="${menu.menuName}"
                                           class="form-control required">
                                <#else>
                                    <input id="menuName" name="parent.name" readonly="readonly" type="text" value="默认一级菜单"
                                           class="form-control required">
                                </#if>
                                <span class="input-group-btn">
                                 <button type="button" id="menuButton" class="btn   btn-primary"><i
                                             class="fa fa-search"></i></button>
                             </span>
                            </div>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label"><font color="red">*</font>名称</label>
                        <div class="col-sm-10">
                            <input id="name" name="name" class="required form-control" type="text" value="" maxlength="50" >
                        </div>
                    </div>



                    <div class="form-group"><label class="col-sm-2 control-label">链接</label>

                        <div class="col-sm-10">
                            <input id="href" name="href" class="form-control " type="text" value=""
                                   maxlength="2000">
                            <span class="help-block m-b-none">点击菜单跳转的页面</span>
                        </div>
                    </div>


                    <#--<div class="form-group">-->
                        <#--<label class="col-sm-2 control-label">目标</label>-->

                        <#--<div class="col-sm-10"><input id="target" name="target" class="form-control " type="text" value="" maxlength="10"></div>-->
                    <#--</div>-->



                    <div class="form-group">
                        <label class="col-sm-2 control-label">图标</label>

                        <div class="col-sm-10">
                            <input id="icon" name="icon" class="form-control " type="text" value="">
                            <span class="help-block m-b-none">参考Font Awesome 4.7.0</span>

                        </div>
                    </div>



                    <div class="form-group">
                        <label class="col-sm-2 control-label"><font color="red">*</font>排序</label>

                        <div class="col-sm-10">
                            <input id="sort" name="sortNum" class="required digits form-control " type="text" value=""
                                   maxlength="50"/>
                            <span class="help-block m-b-none">排列顺序，升序</span>
                        </div>
                    </div>



                    <div class="form-group">
                        <label class="col-sm-2 control-label">可见</label>
                        <div class="col-sm-10">
                                 <span>
                                     <input id="isShow1" name="isShow" class="required i-checks required" type="radio" value="0" checked="checked"/>
                                     <label for="isShow1">显示</label></span><span>
                                <input id="isShow2" name="isShow" class="required i-checks required" type="radio" value="1"/><label for="isShow2">隐藏</label></span>
                            <span class="help-block m-b-none">该菜单或操作是否显示到系统菜单中</span>
                        </div>
                    </div>



                    <div class="form-group">
                        <label class="col-sm-2 control-label">权限标识</label>
                        <div class="col-sm-10"><input id="permission" name="permission" class="form-control " type="text" value="" maxlength="100">
                            <span class="help-block m-b-none">控制器中定义的权限标识，如@RequiresPermissions("权限标识")</span>
                        </div>

                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <textarea id="remarks" name="remarks" maxlength="200" class="form-control" rows="3"></textarea>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-6">
                            <div class="form-group" style=" padding-left: 550px;padding-top: 40px;">
                                <button type="button" class="btn btn-primary" id="enter" >确定</button>
                                <button type="button" class="btn btn-default" id="cancel">取消</button>
                            </div>
                        </div>
                    </div>


                </form>
            </div>
        </div>
    </div>
</div>
</body>
<script src="${request.contextPath}/static/ihomeStatic/js/jquery-1.12.4.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/bootstrap.min.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/bootstrap-table/bootstrap-table.min.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/layer/layer.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/treeTable/js/jquery.treeTable.min.js"></script>
<script src="${request.contextPath}/static/ihomeStatic/js/icheck/js/icheck.min.js"></script>
<script>
    $("#menuButton, #menuName").click(function(){
        var id = $("#menuId").val();
        // // 是否限制选择，如果限制，设置为disabled
        if ($("#menuButton").hasClass("disabled")){
            return true;
        }
        // 正常打开
        layer.open({
            type: 2,
            area: ['300px', '420px'],
            title:"选择菜单",
            content: "${request.contextPath}/menuManage/tree",
        });
    });

    $("#enter").click(function () {
        var parentId = $("#parentId").val();
        var name = $("#name").val();
        var url = $("#href").val();
        var icon = $("#icon").val();
        var sort = $("#sort").val();
        var permission = $("#permission").val();
        var remarks = $("#remarks").val();

        $.ajax({
            url:"${request.contextPath}/menuManage/add",
            type:"get",
            data:{menuName:name,parentId:parentId,url:url,icon:icon,orderNum:sort,visible:$('input:radio:checked').val(),perms:permission,remark:remarks},
            success:function (data) {
                if (data.code!=null || data.code!=''){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.$("#hi1").val("1");
                    parent.layer.close(index);//关闭当前页
                }
            } ,
            error:function (){
            }
        });



    });

    $("#cancel").on('click',function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);//关闭当前页
    });




</script>
</html>